import 'package:flutter/material.dart';
import 'package:flutter_swiper/flutter_swiper.dart';
import 'package:flutterapp/fileUpload/demo.dart';

void main()=>runApp(MaterialApp(home: Banner(),));

class Banner extends StatefulWidget {
  @override
  _BannerState createState() => _BannerState();
}

class _BannerState extends State<Banner> {

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
//    this.isTrue();
  }

  List<Map> imgList=[
    {"url":'images/fileUpload/1.png'},
    {"url":'images/fileUpload/2.png'},
    {"url":'images/fileUpload/3.png'},
  ];

  // 分页指示器
  buildSwiperPagination() {
    return SwiperPagination(
      //指示器显示的位置
      alignment: Alignment.bottomCenter, // 位置 Alignment.bottomCenter 底部中间
      // 距离调整
      margin: const EdgeInsets.fromLTRB(0, 0, 0, 5),
      // 指示器构建
      builder: DotSwiperPaginationBuilder(
        // 点之间的间隔
          space: 2,
          // 没选中时的大小
          size: 6,
          // 选中时的大小
          activeSize: 12,
          // 没选中时的颜色
          color: Colors.black54,
          //选中时的颜色
          activeColor: Colors.white
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          backgroundColor: Colors.white,
          title: Text(
            '证件采集系统',
            style: TextStyle(
              color: Colors.black,
            ),
          ),
        ),
        body: Column(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: <Widget>[
            Container(
              padding: EdgeInsets.fromLTRB(0, 20, 0, 20),
              width: 350,
              height: 540,
              child: Swiper(
                itemBuilder: (BuildContext context,int index){
                  return new Image.asset(
                    imgList[index]['url'],
                    fit: BoxFit.fill,
                  );
                },
                itemCount: imgList.length,
                pagination: new SwiperPagination(
                  margin: const EdgeInsets.all(0.0),
                  alignment: Alignment.bottomCenter,
                  builder: DotSwiperPaginationBuilder(
                    color: Colors.white,
                    activeColor: Colors.black,
                    size: 8,
                    activeSize: 8,
                  )
                ),
                loop: true,
                autoplay: true,
              ),
            ),

            Container(
              width: 500,
              padding: EdgeInsets.fromLTRB(15, 0, 15, 0),
              child: FlatButton(
                shape: RoundedRectangleBorder(
                  borderRadius: BorderRadius.circular(100),
                ),
                child: Text('我知道了，去拍证件照'),
                textColor: Colors.white,
                color: Colors.blueAccent,
                disabledColor: Colors.lightBlueAccent,
                onPressed: (){
                  Navigator.of(context).push(
                    MaterialPageRoute(
                      builder: (context)=> HttpDemo(),
                    )
                  );
                },
              ),
            ),
          ],
        ),

    );
  }
}
